/**
 * 计算进度百分比
 * @param startDate 开始日期
 * @param endDate 结束日期
 * @returns 进度百分比（0-100）
 */
export const calculateProgress = (startDate: string, endDate: string): number => {
  const start = new Date(startDate).getTime();
  const end = new Date(endDate).getTime();
  const now = new Date().getTime();

  if (now <= start) return 0;
  if (now >= end) return 100;

  const total = end - start;
  const current = now - start;
  return Math.round((current / total) * 100);
};

/**
 * 格式化日期显示
 * @param date ISO日期字符串
 * @returns 格式化后的日期字符串 (YYYY-MM-DD)
 */
export const formatDate = (date: string): string => {
  return new Date(date).toISOString().split('T')[0];
};

/**
 * 验证日期范围
 * @param start 开始日期
 * @param end 结束日期
 * @returns 是否有效
 */
export const isValidDateRange = (start: string, end: string): boolean => {
  const startDate = new Date(start);
  const endDate = new Date(end);
  return startDate < endDate;
}